<?php
//debug($users);
 $this->passedArgs['status']=$this->params['named']['status'];
 $this->Paginator->options(array('url' => $this->passedArgs));
?>

<table width="1024px">
    <tr ><td><div  style="float:right">
            
            
     <?php //echo $this->Html->link(        $this->Html->image('../img/add_more.png', array('alt' =>'Add more')),array('action'=>'admin_register'),array('escape' => false,'class'=>'noprint')); ?></div></div></td></tr>
    <tr><td>&nbsp;</td></tr>
    <tr>
        <td>

            <table width="100%" id="table" >
                <tr >
                    <th width="224px"><?php echo $this->Paginator->sort("Login",'username'); ?></th>
                    <th width="250px"><?php echo $this->Paginator->sort("Email",'email'); ?></th>
                     <th width="40px"><?php echo $this->Paginator->sort("Points",'SUM(UserCredit.credit)'); ?></th>
                      <th width="40px">Reg. Date</th>
                      <th width="40px">&nbsp;</th>
                    <th width="40px">Edit</th>
                    <th width="40px">Delete</th>
                    
                </tr>
<?php foreach ($users as $data): ?>
                    <tr id="table_content">
                        <td><?php echo $data['User']['username'];?></td>
                        <td><?php echo $data['User']['email']; ?></td>
                        <td><?php $points='0';
                                foreach ($data['UserCredit'] as $credit){
                                    $points+=$credit['credit'];
                                }
                                echo $points;
                            ?>
                        </td>
                        <td><?php echo $data['User']['created'] ;?></td>
                        <td><?php echo $this->Html->link("Sign In",array('action'=>'admin_sign_in',$data['User']['id']),array('target'=>'_blank')); ?></td>
                        <td><?php echo $this->Html->link($this->Html->image('user_edit.png', array('alt' => 'Edit','title'=>'edit' ,'border'=>'0')), array('action' => 'admin_edit', $data['User']['id'],'?'=>array('points'=>$points)), array('escape' => false)); ?></td>
                        <td><?php echo $this->Html->link($this->Html->image('trash.png', array('alt' => 'Delete','title'=>'Delete' ,'border'=>'0')), array('action' => 'admin_delete', $data['User']['id'],'?'=>array('type'=>'user','status'=>$data['User']['status'])), array('escape' => false,'onclick'=>"return confirm('Are you sure you want to delete?')")); ?></td>
                    </tr>
                        <?php endforeach; ?>
                <tr>
                    <td><?php
                        echo $this->Paginator->numbers();
                      

                        ?>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>




